<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/css/layui.css" th:href="@{/css/layui.css}" media="all">
</head>
<body>
<div style="margin: 15px">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>登录</legend>
    </fieldset>
    <input hidden="hidden" th:value="${tip}" id="index-tip">
    <form class="layui-form" method="post" action="/user/login">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入用户名"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" lay-verify="pass" autocomplete="off" placeholder="请输入密码"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/js/layui.js" th:src="@{/js/layui.js}" charset="UTF-8"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js" th:src="@{https://code.jquery.com/jquery-3.5.1.min.js}"
        type="application/javascript"></script>
<script type="application/javascript">
    const val = $("#index-tip").val();
    if (val === "1") {
        alert("用户名不存在");
        location.href = "/";
    }
</script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
</body>
</html>